package com.example.myzhugezhaofang.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.example.myzhugezhaofang.R;

import java.util.List;

/**
 * 作者：朱勇闯
 * data : 2021/4/11  19:17
 * 作用： xxxx
 */
public class TagAdapter extends RecyclerView.Adapter<TagAdapter.HomeHolder> {
    private Context context;
    private List<String> tags;

    public TagAdapter(Context context, List<String> tags) {
        this.context = context;
        this.tags = tags;
    }

    @NonNull
    @Override
    public HomeHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View v = LayoutInflater.from(context).inflate(R.layout.item_tag_like, parent, false);
        return new HomeHolder(v);
    }

    @Override
    public void onBindViewHolder(@NonNull HomeHolder holder, int position) {
        holder.tv.setText(tags.get(position));
    }

    @Override
    public int getItemCount() {
        return tags.size();
    }

    class HomeHolder extends RecyclerView.ViewHolder {
        private TextView tv;

        public HomeHolder(@NonNull View itemView) {
            super(itemView);
            tv = itemView.findViewById(R.id.tv_tags_like);
        }
    }
}
